﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>

     <title>节点-事件</title>
    <link href="../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />

    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>

    <script type="text/javascript">
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");

            //初始化groupID.
            var nodeID = GetQueryString("FK_Node");

            var ens = new Entities("BP.Sys.FrmEvents");
            ens.Retrieve("FK_Node", nodeID);

            var html = "<table style='width:98%;'>";
            html += "<caption><img src='../../Img/Event.png' />节点事件 </caption>";
            html += "<tr>";
            html += "<th>序</th>";
            html += "<th>事件标记</th>";
            html += "<th>事件</th>";
            html += "<th>类型</th>";
            html += "<th>内容</th>";
            html += "<th>操作</th>";
            html += "</tr>";

            for (var i = 0; i < ens.length; i++) {

                var en = ens[i];

                html += "<tr>";
                html += "<td class=Idx>" + (i+1)+ "</td>";
                html += "<td>" + en.FK_Event + "</td>";
                html += "<td>" + GetActionTypeName(en.FK_Event) + "</td>";
                html += "<td>" + GetDoType(en.EventDoType) + "</td>";
                html += "<td>" + en.DoDoc + "</td>";
                html += "<td><a href=\"javascript:Delete('" + en.MyPK + "')\"><img src='../../Img/Btn/Delete.gif' border=0 />删除</a></td>";
                html += "</tr>";
            }
            html += "</table>";

            $("#Msg").html(html);
        });

        function New() {
            var url = "ActionDtl.htm?FK_Node=" + GetQueryString("FK_Node");
            window.location.href = url;
        }

        function Delete(mypk) {

            if (confirm('您确定要删除吗？') == false)
                return;

            var en = new Entity("BP.Sys.FrmEvent", mypk);
            en.Delete();
            window.location.href = window.location.href;
            return;
        }
        function GetActionTypeName(type) {

            //事件类型.
            var eventLists = [
            { No: "WorkArrive", Name: "工作到达", IsHaveMsg: 1, Note: '到达当前的工作的时候.' },
            { No: "SendWhen", Name: "当节点发送前", IsHaveMsg: 0, Note: '发送前事件，可以抛出异常阻止流程向下发送.' },
            { No: "SendSuccess", Name: "节点发送成功时", IsHaveMsg: 1, Note: '成功的事件.' },
            { No: "SendError", Name: "节点发送失败时", IsHaveMsg: 0, Note: '失败后的处理业务.' },
            { No: "ReturnBefore", Name: "当节点退回前", IsHaveMsg: 0, Note: '退回前的业务逻辑，可以抛出异常阻止退回.' },
            { No: "ReturnAfter", Name: "当节点退回后", IsHaveMsg: 1, Note: '退回后的业务逻辑.' },
            { No: "UndoneBefore", Name: "当节点撤销发送前", IsHaveMsg: 0, Note: '可以抛出异常阻止撤销动作.' },
            { No: "UndoneAfter", Name: "当节点撤销发送后", IsHaveMsg: 1, Note: '.' },
            { No: "WhenReadWork", Name: "工作打开后", IsHaveMsg: 0, Note: '打开工作的时候，就是接受人阅读的时候.' }
            ]

            for (var i = 0; i < eventLists.length; i++) {
                var en = eventLists[i];
                if (en.No == type)
                    return en.Name;
            }
            return "xxxx";
        }

        function GetDoType(doType) {

            var cfg = "@0=禁用@1=执行存储过程@2=执行SQL语句@3=执行URL@4=WebServices(未完成)@5=执行ddl文件的类与方法@6=EventBase类@7=业务单元";

            var cfgs = cfg.split('@');

            for (var i = 0; i < cfgs.length; i++) {
                var vss = cfgs[i];
                if (vss.indexOf('=') == -1)
                    continue;
                var vals = vss.split('=');
                if (vals[0] == doType)
                    return vals[1];
            }
            return doType + 'ss';
        }
        function Help() {
            var url = "http://ccbpm.mydoc.io";
            window.open(url);
        }
    </script>
</head>
<body  >
	<form id="cc">
	 
     <div id="Msg"></div>
     
     <br />
     <input type=button value="+新建节点事件"  onclick="javascript:New()" />
     <input type=button value="什么是节点事件？"  onclick="javascript:Help()" />


	</form>
</body>
</html>
